package cn.tedu.charging.user.dao.repository.impl;

import cn.tedu.charging.common.pojo.po.ChargingVehiclePO;
import cn.tedu.charging.user.dao.mapper.ChargingVehicleMapper;
import cn.tedu.charging.user.dao.repository.VehicleRepository;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class VehicleRepositoryImpl implements VehicleRepository {
    @Autowired
    private ChargingVehicleMapper chargingVehicleMapper;


    @Override
    public ChargingVehiclePO getVehicleDetailById(Integer vehicleId) {
       return chargingVehicleMapper.selectById(vehicleId);
    }

    @Override
    public void save(ChargingVehiclePO vehicle) {
        chargingVehicleMapper.insert(vehicle);
    }

    @Override
    public ChargingVehiclePO getVehicleByLicense(String license) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("license",license);
        if (chargingVehicleMapper.selectOne(queryWrapper)!=null){
            return chargingVehicleMapper.selectOne(queryWrapper);
        }
        return null;
    }
}
